package com.example.springcloudwinter.service;

import com.example.springcloudwinter.dto.ResultEntity;
import com.example.springcloudwinter.entity.po.FoodPo;
import com.example.springcloudwinter.mapper.FoodMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

@Service
public class FoodService {
    @Autowired
    private FoodMapper foodMapper;

    public ResultEntity<?> listFoodByBusinessId(Integer businessId) {
        ResultEntity<List<?>> result=new ResultEntity<>();
        List<FoodPo> list;
        try {
            list=foodMapper.listFoodByBusinessId(businessId);
            if(list.isEmpty())return result;
            else result.setDetail(list).setCode(200);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return result;
    }
}
